package core.Resource
{
	import flash.display.Bitmap;

	public class MapResManager
	{
		
		private var _mapBmdCache:Array;
		
		public function MapResManager()
		{
			_mapBmdCache = [];	
		}
		
		public static function get instance():MapResManager
		{
			if(_instance == null)
				_instance = new MapResManager();
			return _instance;
		}
		
		public function getMapBlock(name:String):BitmapData
		{
			//TODO:计算出需要读取哪个包
			
			//TODO:如果包已经在读，排入队列
			return _mapBmdCache[name];
			
		}
		
		public function setMapBlock(name:String,bmd:BitmapData):void
		{
			_mapBmdCache[name] = bmd;
		}
		
		
		private function getMapPackNameByBlockName(blockName:String):String
		{
			//每个包打包2*2四块地图
			var splitedBlockName:Array = blockName.split("_");
			var x:int = int(splitedBlockName[0]);
			var y:int = int(splitedBlockName[1]);
			var resultX:int = int(x/2)*2;
			var resultY:int = int(y/2)*2;
			return resultX+"_"+resultY; 
		}
			
		

		
		private static var _instance:MapResManager;
	}
}